#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n, b;
	int ans;
	int flag = -1;
	cin >> n;
	int record;
	vector<int> tableA(n);
	for (auto& pair : tableA)
	{
		cin >> pair;
	}
	for (auto& pair : tableA)
	{
		ans = 0;
		for (auto& elemt : tableA)
		{
			if (pair == elemt)
			{
				ans++;
			}
		}
		if (ans > flag)
		{
			flag = ans;
			record = pair;
		}
		else if(ans==flag)
		{
			if (pair < record)
			{
				record = pair;
			}
		}
	}

	cout << record;
	return 0;
}
